package com.example.zuoye.service.impl;

import com.example.zuoye.dao.CartDAO;
import com.example.zuoye.entity.Cart;
import com.example.zuoye.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CartServiceImpl implements CartService {

    @Autowired
    CartDAO cartDAO;

    @Override
    public boolean addCartService(String objId, String userId) {
        if (userId == null || objId == null){
            return false;
        }
        return cartDAO.addCart(objId,userId);
    }

    @Override
    public boolean deleteCartService(String objId, String userId) {
        if (userId == null || objId == null){
            return false;
        }
        return cartDAO.deleteCart(objId,userId);
    }

    @Override
    public Cart checkedCartService(String objId, String userId) {
        Cart cart = cartDAO.checkedCart(objId,userId);
        System.out.println(cart);
        return cart;
    }

    @Override
    public List<Cart> getListCartService(String userId) {
        return cartDAO.getListCart(userId);
    }
}
